<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('学生列表')"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body class="gray-bg">
<div class="container-div">

    <div class="row">
        <div class="col-sm-12 search-collapse">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-danger multiple" onclick="submitHandler()">
                    <i class="fa fa-remove"></i> 分组
                </a>
                <a class="btn btn-primary single disabled" onclick="$.table.affectedRowIds()">
                    <i class="fa fa-edit"></i> 获取当前页选中或者取消的行ID
                </a>
            </div>
            <div class="select-list">
                <ul>
                    <li>
                        <label style="width: 80px">学生姓名：</label>
                        <input type="text" name="stuName"/>
                    </li>
                    <li>
                        <label style="width: 80px">身份证号码：</label>
                        <input type="text" name="stuIdCard"/>
                    </li>
                    <li>
                        <label style="width: 80px">学院：</label>
                        <input type="text" name="stuCollege"/>
                    </li>
                    <li class="select-selectpicker">
                        <label style="width: 80px">学生状态：</label>
                        <select name="stuStatus" th:with="type=${@dict.getType('fh_student_status')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm m50" onclick="$.table.search()"><i
                                class="fa fa-search"></i>&nbsp;搜索</a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('complex-form')"><i
                                class="fa fa-refresh"></i>&nbsp;重置</a>
                    </li>
                </ul>
            </div>
        </div>


        <div class="row">
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>


</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-select-js"/>
<th:block th:include="include :: jquery-cxselect-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/information";
    var datas = [[${@dict.getType('fh_student_status')}]];

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            updateGroupUrl: prefix + "/editGroup/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            detailUrl: prefix + "/detail/{id}",
            cleanUrl: prefix + "/clean",
            myUrl: prefix + "/getGroup/{id}",
            batchCreateUrl: prefix + "/getGroup",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            search: false,
            // search: true,
            modalName: "用户",
            columns: [{
                checkbox: true
            },
                {
                    field: 'stuId',
                    title: '学生ID',
                },
                {
                    field: 'stuName',
                    title: '学生姓名'
                },
                {
                    field: 'stuSex',
                    title: '性别',
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return "男";
                        } else if (value == 1) {
                            return "女";
                        } else {
                            return "--";
                        }
                    }

                },
                {
                    field: 'stuIdCard',
                    title: '身份证号码'
                },
                {
                    field: 'stuCollege',
                    title: '学院',
                    formatter: function (value, row, index) {
                        if (index == 0) {
                            value = value;
                        }
                        return $.table.tooltip(value, 4, "open");
                    }
                },
                {
                    field: 'stuClass',
                    title: '班级'
                },
                {
                    field: 'stuAddress',
                    title: '家庭地址',
                    formatter: function (value, row, index) {
                        if (index == 0) {
                            value = value;
                        }
                        return $.table.tooltip(value, 6, "open");
                    }
                },
                {
                    field: 'stuBirthday',
                    title: '生日'
                },
                {
                    field: 'stuPhoneNumber',
                    title: '联系电话'
                },
                {
                    field: 'stuHomePhoneNumber',
                    title: '学生家庭联系电话'
                },
                {
                    field: 'stuInstructor',
                    title: '导员'
                },
                {
                    field: 'stuHeadTeacher',
                    title: '班主任'
                },
                {
                    field: 'stuHeadTeacherPhoneNumber',
                    title: '班主任联系电话'
                },
                {
                    field: 'stuStatus',
                    title: '学生状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:;" onclick="$.operate.editGroup(\'' + row.stuId + '\')"><i class="fa fa-edit"></i>分组</a> ');
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:;" onclick="$.operate.edit(\'' + row.stuId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:;" onclick="$.operate.detail(\'' + row.stuId + '\')"><i class="fa fa-search"></i>详细</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:;" onclick="$.operate.remove(\'' + row.stuId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);


    });

    /* 添加用户-选择用户-提交 */
    function submitHandler() {
        var rows = $.table.selectFirstColumns();
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        var data = {"roleId": $("#roleId").val(), "userIds": rows.join()};
        $.operate.save(prefix + "/selectAll", data);
    }

</script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                &nbsp; <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i
                    class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>